home *** CD-ROM | disk | FTP | other *** search
/ Delphi Developer's Kit 1996 / Delphi Developer's Kit 1996.iso / power / enterctl / edbedit.pas next >
Pascal/Delphi Source File  |  1995-12-22  |  1KB  |  69 lines

  1. unit Edbedit;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Mask, DBCtrls;
  8.  
  9. type
  10.   TEDBEdit = class(TDBEdit)
  11.   private
  12.     { Private declarations }
  13.   protected
  14.     { Protected declarations }
  15.     procedure KeyPress(var Key: Char); override;
  16.     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
  17.   public
  18.     { Public declarations }
  19.   published
  20.     { Published declarations }
  21.   end;
  22.  
  23. procedure Register;
  24.  
  25. implementation
  26.  
  27. procedure Register;
  28. begin
  29.   RegisterComponents('Samples', [TEDBEdit]);
  30. end;
  31.  
  32. procedure TEDBEdit.KeyPress(var Key: Char);
  33. var
  34.    MYForm: TForm;
  35. begin
  36.  
  37.    if Key = #13 then
  38.    begin
  39.        MYForm := GetParentForm( Self );
  40.        if not (MYForm = nil ) then
  41.            SendMessage(MYForm.Handle, WM_NEXTDLGCTL, 0, 0);
  42.        Key := #0;
  43.    end;
  44.  
  45.    if Key <> #0 then inherited KeyPress(Key);
  46.  
  47. end;
  48.  
  49. procedure TEDBEdit.KeyDown(var Key: Word; Shift: TShiftState);
  50. var
  51.    MYForm: TForm;
  52.    CtlDir: Word;
  53. begin
  54.  
  55.    if (Key = VK_UP) or (Key = VK_DOWN) then
  56.    begin
  57.        MYForm := GetParentForm( Self );
  58.        if Key = VK_UP then CtlDir := 1
  59.        else CtlDir :=0;
  60.        if not (MYForm = nil ) then
  61.            SendMessage(MYForm.Handle, WM_NEXTDLGCTL, CtlDir, 0);
  62.    end
  63.    else inherited KeyDown(Key, Shift);
  64.  
  65. end;
  66.  
  67.  
  68. end.
  69.